<HTML>
<HEAD>
<TITLE>ATL 8.0 test page for object Mydn</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript">
function OnLoad()
{
	try{
        document.getElementById('idtest').setpath(GetPathDir());
	} catch (e){
		DbgTrace(e);
	}
}
function OnTest()
{
	try{
		document.getElementById('idtest').update(function (a, b){
			DbgTrace(a + ':' + b);
		});
	} catch (e){
		DbgTrace(e);
	}
}

function DbgTrace(str){
	document.getElementById('idmsg').innerHTML = str;
}

function OnGetList(){
    try{
		document.getElementById('data').innerHTML = document.getElementById('idtest').getlist();
    } catch (e) {
        DbgTrace(e)
    }
}

function OnGetUUID(){
    try{
		document.getElementById('data').innerHTML = document.getElementById('idtest').getuuid();
    } catch (e) {
        DbgTrace(e)
    }
}

function GetPathDir()
{
	var 	reg1		= /^file:\/\/\/[a-zA-Z]:\/.*/g;
	var		reg2		= /^file:\/\/\/.*/g;
	var		path		= String(document.location);
	var		last		= path.lastIndexOf("/");
	
	// 去除文件名
	if(-1 == last){
		last = path.lastIndexOf("\\");
	}
	if(-1 != last){
		path = path.substring(0, last+1);
	}
	// 去除前缀
	if(reg1.test(path)){
		path = String(path).substr(8);
	} else if(reg2.test(path)){
		path = String(path).substr(7);
	} else {
		path = String(path);
	}
	
	return path;
}
</script>
</HEAD>
<BODY>


<OBJECT ID="idtest" CLASSID="CLSID:E188CCD7-1FF1-4673-A4A5-34410DB2B22B" WE=100 type="application/x-mydn-localstorage"></OBJECT>

<button onClick="OnTest()">测试</button><br>
<button onClick="OnGetList()">获取数据</button><br>
<button onClick="OnGetUUID()">获取UUID</button>
<div id='data'></div>
<div id='idmsg' style='color:red'></div>
</BODY>
</HTML>
